/*******************************************************************************

    
    Cloud Firewall - a browser extension/addon that allows users to block connections 
    to sites, pages and web resources (images, videos, etc) hosted in major cloud services
    if the user wishes to do so.
    Copyright (C) 2019 Niklas Poslovski
    Copyright (C) 2019 Gokulakrishna Sudharsan

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.

    Home: https://notabug.org/nipos/cloud-firewall
*/

// Some sites that are not just hosted in any cloud. 
// If you are reviewing this, please let me know how to update this list
var some_nonbig5domains = ["eff.org","fsf.org","gnu.org","archive.org","wikipedia.org","debian.org","trisquel.info","puri.sm","pureos.net","parabola.nu","torproject.org","archlinux.org","fuckoffgoogle.de","fuckoffgoogle.net","nomoregoogle.com","dns.digitale-gesellschaft.ch"];

// The below is just to speed up, as there's no need for number crunching process 
//   of "Is IP address present in IP ranges" when the domain name just says "{cloud}.com" ! 

// We have this so we can speed up the request handler and not search in whole IP range CIDR blocks for
// for well known hostnames owned by or hosted on these 5 clouds. 
// If you are reviewing this, please let me know how to update this list:

// Instagram is owned by facebook and hosted on AWS..? 
// adding it to both facebook and amazon list so user can expect to block the site when Facebook toggle is ON
// we also need to consider it blocked on normal functionality based on hosted place, so it's on AWS list too.

// Discord Messenger is protected by Cloudflare CDN but the real servers are rented at Google Cloud so we're blocking it for both.

// Github still has their own datacenter and isn't hosted at Microsoft Azure but the company belongs to them so we're blocking it.

var knownbig5domains = {
google:["google.com","googleusercontent.com","googletagmanager.com","doubleclick.net","googlesyndication.com","gstatic.com","blogspot.com","youtube.com","youtu.be","youtube-nocookie.com","googleapis.com","googletagservices.com","googleadservices.com","googlecommerce.com","ytimg.com","ggpht.com","gitlab.com","gitlab-static.net","gitlab.io","google-analytics.com","googlevideo.com","adsensecustomsearchads.com","goo.gl","discordapp.com","discord.gg","discord.com","withgoogle.com","ampproject.org"],
amazon:["amazon.com","cloudfront.com","awsstatic.com","instagram.com","amazonaws.com","amazon-adsystem.com","associates-amazon.com","media-amazon.com","ssl-images-amazon.com","alexa.com"],
facebook:["facebook.com","fbcdn.net","fbcdn.com","whatsapp.com","instagram.com","cdninstagram.com"],
apple:["apple.com","icloud.com"],
microsoft:["microsoft.com","bing.com","github.com","githubapp.com","githubassets.com","githubusercontent.com","windows.com","xbox.com","linkedin.com","office.com","licdn.com","microsoftonline.com","windows.net","aspnetcdn.com"],
cloudflare:["cloudflare.com","cloudflare.net","discordapp.com","discord.gg","discord.com","gitlab.com"]
};
 //Like amazon has aws, elb, s3, cloudfront, what does Cloudflare have for their services to identify on the URL?
